#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define left LEFT
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const LL LINF = 1ll << 32;
const int INF = 2147483647;
const ldb pi = fabsl(atan2(0.0, -1.0));
using namespace std;

int d[310][310];
vector <int> cnt[310];
int loc[20010];
bool was[310];
int n, m, K, S;
int T;
ldb all;

void Load()
{	
	scanf("%d%d%d", &n, &m, &K);
	int i, j;
	for (j = 0; j < n; j++) cnt[j].resize(0);
	for (i = 1; i <= K; i++)
	{
		scanf("%d", &loc[i]);
		cnt[loc[i]].push_back(i);
	}
	int a, b, c;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			d[i][j] = INF;
		}
		d[i][i] = 0;
	}
	for (i = 0; i < m; i++)
	{
		scanf("%d%d%d", &a, &b, &c);
		d[a][b] = c;
		d[b][a] = c;
	}
}

int ans[20000];
int cans[20000];
int sz, rsz;
LL cur, res;
int left;
int st[331][331];

int GVER;
inline bool cmp(int a, int b)
{
	return cnt[a].size() > cnt[b].size() || d[GVER][a] < d[GVER][b] && cnt[a].size() == cnt[b].size();
}
int steps;

void go(int ver)
{
	steps++;
	if (cur >= res) return;
	if (left == 0)
	{
		res = cur;
		int i;
		rsz = sz;
		for (i = 0; i < sz; i++)
		{
			ans[i] = cans[i];
		}
		return;
	}
	if (steps > 500000 / T) return;
	int i;
	was[ver] = 1;
	st[ver][0] = 1;
	for (i = 0; i < n; i++)
	{
		if (was[i] == 0 && d[ver][i] < INF && cnt[i].size() > 0)
		{
			st[ver][st[ver][0]++] = i;
		}
	}
	GVER = ver;
	sort(st[ver] + 1, st[ver] + st[ver][0], cmp);
	int j;
	for (i = 1; i < st[ver][0] && i < S; i++)
	{
		j = st[ver][i];
		cur += (LL)left * d[ver][j];
		left -= cnt[j].size();
		cans[sz++] = j;
	//	cerr << "going to " << j << " having cur res = " << cur << " with new left " << left << " dst " << d[ver][j] << "\n";
		go(j);
		sz--;
		left += cnt[j].size();
		cur -= (LL)left * d[ver][j];
		
	}
	was[ver] = 0;
}

void Solve()
{
	int i, j, k;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			for (k = 0; k < n; k++)
			{
				if (d[j][i] < INF && d[i][k] < INF)
					d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}
	for (i = 0; i < n; i++) was[i] = 0;
	left = K;
	res = 1ll << 60;
	rsz = 0;
	for (S = 1; S <= 5; S++)
	{          
		cur = 0;
		sz = 0;
		steps = 0;
		go(0);
	}
//	all += (ldb)res / (ldb)K;
//	cerr << "Current score = " << setprecision(6) << fixed << (ldb)res / (ldb)K << "\n";
//	cerr << "Current res = " << res << "\n";
	for (i = 0; i < rsz; i++)
	{
		for (j = 0; j < cnt[ans[i]].size(); j++)
		{
			printf("%d ", cnt[ans[i]][j]);
		}
	}
	printf("\n");
}

#define file "allinone"
int main()
{
//	freopen(file".in", "rt", stdin);
//	freopen(file".out", "wt", stdout);
	cin >> T;
	int i;
	for (i = 0; i < T; i++)
	{
		Load();
		Solve();
	}
//	cerr << "Score is " << setprecision(6) << fixed << all << "\n";
	return 0;
}

